package cn.csq.design.structural.adapter.object;

import cn.csq.design.structural.adapter.Player;
import cn.csq.design.structural.adapter.Translator;
import cn.csq.design.structural.adapter.ZH_JPTranslator;

/**
 * 适配器模式 组合的模式
 * @author csq
 * @date 2022/1/27 10:55:30
 */
public class JPMoviePlayerAdapter2 implements Player {

    //组合的方式
    private Translator translate;

    private Player target;//被适配对象

    public JPMoviePlayerAdapter2(Player target) {
        this.target = target;
    }

    public JPMoviePlayerAdapter2(Player target, Translator translate) {
        this.translate = translate;
        this.target = target;
    }
    @Override
    public String play() {
        String play = target.play();
        //转换字幕
        return this.translate.translate(play);
    }

   }
